package com.leyou.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.common.dto.SpuDetailDTO;
import com.leyou.item.entity.SpuDetail;
import com.leyou.item.mapper.SpuDetailMapper;
import com.leyou.item.service.SpuDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


@Service
public class SpuDetailServiceImpl extends ServiceImpl<SpuDetailMapper, SpuDetail> implements SpuDetailService {

    @Autowired
    private SpuDetailService spuDetailService;

    @Override
    public List<SpuDetailDTO> querSpuDeatilById(Integer id) {
        List<SpuDetail> list = spuDetailService.query().eq("spu_id", id).list();
        List<SpuDetailDTO> collect = list.stream().map(SpuDetailDTO::new).collect(Collectors.toList());
        return collect;
    }
}
